
<?php

class bd{
	
	private $con;
	
	public function __construct($db="volei_torneig", $servidor="localhost", $usr="root", $pass="")
		{
			$this->con = mysql_connect($servidor, $usr, $pass) or 	die("Error en la connexio");
			mysql_select_db($db, $this->con) or die("NO s'ha localitzat la base de dades");
		}

		
		
	private  function toArray($rs)
	{
		$array = array();
		if(empty($rs)) return $array;
		$aux = mysql_fetch_array($rs);
		while($aux!=false)
		{
			array_push($array,$aux);
			$aux = mysql_fetch_array($rs);
		}
		return $array;
	}

    public function consulta($sql)
    {
        $rows=mysql_query($sql,$this->con);
        return $this->toArray($rows);        
    }
	
	public function executar($sql)
    {
        $fet=mysql_query($sql,$this->con);
        return $fet;        
    }
		
		
}
	?>